/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sbbs;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.transaction.UserTransaction;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Before;

/**
 *
 * @author Administrator
 */
public class LocalBaseTestCase {

    Logger logger = LogManager.getLogger(this.getClass().getName());
    public EntityManager em;
    public EntityManagerFactory entityManagerFactory;
    @Inject
    public UserTransaction utx;
    @Before
    public void init() {
        this.logger.debug("init before test.");
        entityManagerFactory = Persistence.createEntityManagerFactory("DEFAULT");
        em = entityManagerFactory.createEntityManager();
    }

    @After
    public void destroy() {
           this.logger.debug("destory after test.");
        em.close();
        entityManagerFactory.close();
    }

    public EntityManager getEm() {
           this.logger.debug("get entity manager.");
        return this.em;
    }

}
